package com.dongdongshop.serviceimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbAddressMapper;
import com.dongdongshop.pojo.TbAddress;
import com.dongdongshop.pojo.TbAddressExample;
import com.dongdongshop.service.TbAddressService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
@org.springframework.stereotype.Service
public class TbAddressServiceImpl implements TbAddressService {
@Autowired
private TbAddressMapper tbAddressMapper;
    //查询所有地址
    @Override
    public List<TbAddress> findall(String username) {
        List<TbAddress> tbAddresses = tbAddressMapper.selectByUsernameAddress(username);
        return tbAddresses;
    }

    //增加地址
    @Override
    public Boolean insetAddress(TbAddress tbAddress) {
        int i = tbAddressMapper.insertSelective(tbAddress);
        if (i>0){
            return true;
        }
        return false;
    }

    //查询地址回显
    @Override
    public TbAddress selectAddressById(Long id) {
        TbAddress tbAddress = tbAddressMapper.selectaddressByPrimaryKey(id);
        return tbAddress;
    }

    //删除地址
    @Override
    public Boolean deleteAddress(Long id) {
        int i = tbAddressMapper.deleteByPrimaryKey(id);
        if (i>0){
            return true;
        }
        return false;
    }
}
